<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBasicCommentTable extends Migration
{
    /**
     * 评论
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('basic_comment', function (Blueprint $table) {
            $table->increments('id');
            $table->tinyInteger('site_id', false, true)->default(0)->comment('站点编号 默认 0:单站点;');
            $table->text('content')->nullable()->comment('评论内容');
            $table->integer('from_uid', false, true)->default(0)->comment('评论人编号');
            $table->integer('to_uid', false, true)->default(0)->comment('被评论人编号');
            $table->integer('root_id', false, true)->default(0)->comment('跟节点编号');
            $table->integer('parent_id', false, true)->default(0)->comment('上级节点编号');
            $table->string('from_nickname', 100)->nullable()->comment('评论者昵称');
            $table->string('to_nickname', 100)->nullable()->comment('被评论昵称');
            $table->integer('click', false, true)->default(0)->comment('点击量');
            $table->integer('support', false, true)->default(0)->comment('支持数');
            $table->integer('comment', false, true)->default(0)->comment('评论数');
            $table->integer('collect', false, true)->default(0)->comment('搜藏数');
            $table->integer('reply', false, true)->default(0)->comment('回复数');
            $table->char('ip', 15)->nullable()->comment('ip地址');
            $table->char('object_model')->nullable()->comment('模型名称');
            $table->char('object_id')->default(0)->comment('数据编号');
            $table->text('more')->nullable()->comment('扩展字段');
            $table->index(['site_id', 'object_model', 'object_id', 'ip']);
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('basic_comment');
    }
}
